﻿using CommunicationLib.Enums;
using CommunicationLib.Interface;
using CommunicationLib.Model;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace CommunicationLib.Base
{
    public abstract class CommunicationBase : ICommunication
    {
        /// <summary>
        ///    通讯模式
        /// </summary>
        public CommunicationMode CommunicationMode =CommunicationMode.TCP;
        /// <summary>
        /// 串口通讯
        /// </summary>
        public SerialPort serialPort { get; internal set; }
        /// <summary>
        /// 网口通讯
        /// </summary>
        public TcpClient tcpClient {  get; internal set; }
        /// <summary>
        /// 当前数据包
        /// </summary>
        internal DataPackage Package;
        /// <summary>
        /// 连接状态
        /// </summary>
        public bool Connected { get;internal set; }
        /// <summary>
        /// 环形缓冲区管理器
        /// </summary>
        internal RingBufferManager RingBuffer{ get; set; }
        /// <summary>
        /// 环形缓冲区锁
        /// </summary>
        internal object lockRingBuffer { get; set; } = new object();
        public abstract void Send(DataPackage dataPackage);

        public abstract bool Start();


        public abstract bool Stop();
       
    }
}
